#include <iostream>
using namespace std;

class Base
{
public:
  static int m_a;

  static void func()
  {
    cout << "Base func" << endl;
  }
  static void func(int a)
  {
    cout << "Son func" << a << endl;
  }
};

int Base::m_a = 100;

class Son : public Base
{
public:
  static int m_a;

  static void func()
  {
    cout << "Son func" << endl;
  }
};

int Son::m_a = 200;

void test()
{
  Son s;

  // 1. 通过对象访问
  cout << "通过对象访问" << endl;
  cout << "Son m_a = " << s.m_a << endl;
  cout << "Base m_a = " << s.Base::m_a << endl;

  // 2. 通过类名访问
  cout << "通过类名访问" << endl;
  cout << "Son m_a = " << Son::m_a << endl;
  // 第一个:: 代表通过类名方式访问，第二个::代表访问父类作用域下
  cout << "Base m_a = " << Son::Base::m_a << endl;

  // 同名静态成员函数
  // 1. 通过对象访问
  cout << "通过对象访问 静态成员函数" << endl;
  s.func();
  s.Base::func();

  // 2. 通过类名访问
  cout << "通过类名访问" << endl;
  Son::func();
  Son::Base::func();
  Son::Base::func(100);
}

int main(int argc, char const *argv[])
{
  test();

  return 0;
}